import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    loginStatus: '',
    profileFrom: {}
  },
  mutations: {
    // 将token保存到loginStatus
    GETSTATUS(state, value) {
      state.loginStatus = value
      console.log('cookie:', state.loginStatus)
    },
    SAVEPROFILE(state, value) {
      const result = JSON.parse(value)
      state.profileFrom = result
      console.log('登录状态', state.profileFrom)
    }
  },
  actions: {
    getStatus(context, value) {
      context.commit('GETSTATUS', value)
    },
    saveProfile(context, value) {
      context.commit('SAVEPROFILE', value)
    }
  },
  modules: {
  }
})
